package com.fengchao;

import com.fengchao.api.config.Constant;
import com.fengchao.api.service.CfgService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;

@EnableAsync
@SpringBootApplication
public class FengchaoApplication implements CommandLineRunner {
    @Autowired
    private Environment env;
    @Autowired
    private CfgService cfgService;

    private static Logger logger = LoggerFactory.getLogger(FengchaoApplication.class);

    public static void main(String[] args) {
        SpringApplication.run(FengchaoApplication.class, args);
    }


    @Override
    public void run(String... strings) throws Exception {
        logger.info("init configMap start");
        Constant.CONFIGMAP = cfgService.getAll();
        logger.info("env:{}", env.getProperty("spring.profiles.active"));
        logger.info("database:{}", env.getProperty("spring.datasource.url"));
    }
}